package website.seamonster.ethegg.dataobject;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import java.sql.Timestamp;

/**
 * Created by 罗海量
 * 2018-07-22 19:53
 */
@Entity
@Table(name = "sys_tx_req")
@Slf4j
@Data
@DynamicInsert
@DynamicUpdate
public class TxReq {

    private Long id;
    private String clientId;
    private String userId;
    private String prCode;
    private String prUserId;
    private Integer buyCnt;
    private Integer txStatus;
    private String errDesc;
    private Timestamp createTime;
    private Long version;

    @Id
    @Column(name = "ID")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Basic
    @Column(name = "CLIENT_ID")
    public String getClientId() {
        return clientId;
    }

    public void setClientId(String clientId) {
        this.clientId = clientId;
    }

    @Basic
    @Column(name = "USER_ID")
    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    @Basic
    @Column(name = "PR_CODE")
    public String getPrCode() {
        return prCode;
    }

    public void setPrCode(String prCode) {
        this.prCode = prCode;
    }

    @Basic
    @Column(name = "PR_USER_ID")
    public String getPrUserId() { return prUserId; }

    public void setPrUserId(String prUserId) { this.prUserId = prUserId; }

    @Basic
    @Column(name = "BUY_CNT")
    public Integer getBuyCnt() {
        return buyCnt;
    }

    public void setBuyCnt(Integer buyCnt) {
        this.buyCnt = buyCnt;
    }

    @Basic
    @Column(name = "TX_STATUS")
    public Integer getTxStatus() {
        return txStatus;
    }

    public void setTxStatus(Integer txStatus) {
        this.txStatus = txStatus;
    }

    @Basic
    @Column(name = "ERR_DESC")
    public String getErrDesc() {
        return errDesc;
    }

    public void setErrDesc(String errDesc) {
        this.errDesc = errDesc;
    }

    @Basic
    @Column(name = "CREATE_TIME")
    public Timestamp getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Timestamp createTime) {
        this.createTime = createTime;
    }


    @Column(name = "VERSION")
    @Version
    public Long getVersion() {
        return version;
    }

    public void setVersion(Long version) {
        this.version = version;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        TxReq req = (TxReq) o;

        if (id != null ? !id.equals(req.id) : req.id != null) return false;
        if (clientId != null ? !clientId.equals(req.clientId) : req.clientId != null) return false;
        if (userId != null ? !userId.equals(req.userId) : req.userId != null) return false;
        if (prCode != null ? !prCode.equals(req.prCode) : req.prCode != null) return false;
        if (prUserId != null ? !prUserId.equals(req.prUserId) : req.prUserId != null) return false;
        if (buyCnt != null ? !buyCnt.equals(req.buyCnt) : req.buyCnt != null) return false;
        if (txStatus != null ? !txStatus.equals(req.txStatus) : req.txStatus != null) return false;
        if (errDesc != null ? !errDesc.equals(req.errDesc) : req.errDesc != null) return false;
        if (createTime != null ? !createTime.equals(req.createTime) : req.createTime != null) return false;
        if (version != null ? !version.equals(req.version) : req.version != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = id != null ? id.hashCode() : 0;
        result = 31 * result + (clientId != null ? clientId.hashCode() : 0);
        result = 31 * result + (userId != null ? userId.hashCode() : 0);
        result = 31 * result + (prCode != null ? prCode.hashCode() : 0);
        result = 31 * result + (prUserId != null ? prUserId.hashCode() : 0);
        result = 31 * result + (buyCnt != null ? buyCnt.hashCode() : 0);
        result = 31 * result + (txStatus != null ? txStatus.hashCode() : 0);
        result = 31 * result + (errDesc != null ? errDesc.hashCode() : 0);
        result = 31 * result + (createTime != null ? createTime.hashCode() : 0);
        result = 31 * result + (version != null ? version.hashCode() : 0);
        return result;
    }
}
